<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    let name = '梁朝伟';
    //数组
    let F4 = ['赵四','小沈阳','刘能','宋小宝'];

    //解构赋值
    // let [zhao, xiao, liu, song] = F4;
    //只使用第一个数据的处理
    // let [zhao] = F4;
    //只使用某一个数据
    // let [,xiao] = F4;
    // let [,,liu, song] = F4;
    // console.log(liu, song);

    //对象
    let obj = {
      name: '刘德华',
      age: 62,
      news: '刘德华要去董宇辉的直播间',
      position: {
        province: '香港',
        street: '长安街 125 号'
      },
      skill: ['演戏','唱歌']
    };

    //痛点: 每次都需要使用 「对象.属性名」的形式访问元素
    // console.log(obj.name);
    // console.log(obj.age);
    // console.log(obj.news);

    //结构赋值
    // let {name, age, news} = obj;
    // let {name} = obj;
    // let {news, age, name} = obj;
    // console.log(name, age, news);
    
    //获取深层次的数据
    let {position: {province, street}, skill: [act, sing]} = obj;
    // console.log(province, street, act, sing);
    //此时 positioin 和 skill 是不可用的
    // console.log(skill);

    //设置变量的别名
    let {name: xingming} = obj;
    console.log(name, xingming);

  </script>
</body>
</html>